﻿using System;
using System.Collections.Specialized;
using System.Globalization;

namespace Test3
{
     class Program
    {
        static bool isToplizMatrix(int[][] matrix)
        {
            int col = matrix.Length;
            int row = matrix[0].Length;
            //i为列
            for (int i = row - 1; i > -1; i--)
            {
                int ii = i + 1;
                for (int j = 1; j < col && ii < row; j++, ii++)
                {
                    if (matrix[j - 1][ii - 1] != matrix[j][ii])
                        return false;
                }
            }
            for (int j = 1; j < col; j++)
            {
                int jj = j + 1;
                for (int i = 1; i < row && jj < col; jj++, i++)
                    if (matrix[jj - 1][i - 1] != matrix[jj][i])
                        return false;
            }

            return true;
        }
        static void Main(string[] args)
        {
            int[][] matr = new int[3][];
            matr[0] = new int[4] { 1, 2, 3, 4 };
            matr[1] = new int[4] { 5, 1, 2, 3 };
            matr[2] = new int[4] { 9, 5, 1, 2 };
            Console.Write(isToplizMatrix(matr));  

        }
    }
}
